'''
Created on 20/06/2013

@author: belentwi
'''


import os
# cur_dir = os.path.dirname(os.path.abspath(__file__))


from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib.enums import TA_CENTER, TA_RIGHT

from geraldo import Report, ReportBand, Label, ObjectValue, SystemField, FIELD_ACTION_COUNT, BAND_WIDTH

class ItemReport(Report):
    title = 'Items del proyecto'

    class band_begin(ReportBand):
        height = 1 * cm
        elements = [
            Label(text='', top=0.1 * cm,
                left=8 * cm),
        ]

    class band_summary(ReportBand):
        height = 0.7 * cm
        elements = [
            Label(text="En total", top=0.1 * cm, left=0),
            ObjectValue(attribute_name='nombre', top=0.1 * cm, left=3 * cm,
                action=FIELD_ACTION_COUNT,
                display_format='%s items encontrados'),
        ]
        borders = {'all': True}

    class band_page_header(ReportBand):
        height = 1.3 * cm
        elements = [
            SystemField(expression='%(report_title)s', top=0.1 * cm,
                left=0, width=BAND_WIDTH, style={'fontName': 'Helvetica-Bold',
                'fontSize': 14, 'alignment': TA_CENTER}),
            Label(text="Fase", top=0.8 * cm, left=0 * cm),
            Label(text="Id Item", top=0.8 * cm, left=3 * cm),
            Label(text="Nombre", top=0.8 * cm, left=6 * cm),
            Label(text="Prioridad", top=0.8 * cm, left=9 * cm),
            Label(text="Version", top=0.8 * cm, left=12 * cm),
            Label(text="Costo", top=0.8 * cm, left=15 * cm),
        ]
        borders = {'bottom': True}

    class band_page_footer(ReportBand):
        height = 0.5 * cm
        elements = [
            Label(text='Sistema de Administracion de Proyectos', top=0.1 * cm, left=0),
            SystemField(expression='Pagina  %(page_number)d de %(page_count)d', top=0.1 * cm,
                width=BAND_WIDTH, style={'alignment': TA_RIGHT}),
        ]
        borders = {'top': True}

    class band_detail(ReportBand):
        height = 0.5 * cm
        elements = [
            ObjectValue(attribute_name='fase.nombre', top=0, left=0 * cm),
            ObjectValue(attribute_name='id', top=0, left=3 * cm, width=7 * cm),
            ObjectValue(attribute_name='nombre', top=0, left=6 * cm, width=7 * cm),
            ObjectValue(attribute_name='prioridad', top=0, left=9 * cm, width=7 * cm),
            ObjectValue(attribute_name='version', top=0, left=12 * cm, width=7 * cm),
            ObjectValue(attribute_name='costo', top=0, left=15 * cm, width=7 * cm),
            
        ]
